<#-- 卡密批量操作功能-->
<#include "../template/template_listPage.ftl">
<@header title="卡密产品管理">
<style type="text/css">
    .table {
        padding: 1px;
        text-align: center;
    }
</style>
<script type="text/javascript">
    $().ready(function () {
        queryImportBatch('importBatchNum');
    });
    function queryImportBatch(id) {
        var importDate = $('#importDate').val();
        $.ajax({
            type:"POST",
            url:"${web_base}/recharge/card_info!queryImportBatch.htm",
            data:"importDate=" + importDate,
            success:function (data) {
                var dataObj = eval("(" + data + ")");
                var html = '';
                html = '<option value="">--请选择--</option>';
                $.each(dataObj, function (i, n) {
                    html = html + '<option value="' + n + '">' + n + '</option>';
                });
                $('#' + id).html(html);
            }
        });
    }
    /**
     *
     * @param functionno 功能号(1,启用和禁用;2,退卡;3,设置优先级)
     * @param enable
     */
    function functionOpt(functionno, enable) {

        var importBatchNum = $('#importBatchNum').val();
        if (importBatchNum == '' || functionno == undefined || functionno == '') {
            return;
        }
        var data = 'functionno=' + functionno + "&importBatchNum=" + importBatchNum;
        //1,启用和禁用;2,退卡;3,设置优先级
        if (functionno == '1') {
            data = data + "&enable=" + enable;
        } else if (functionno == '2') {
            data = data + "&backcard=true";
        } else if (functionno == '3') {
            data = data + "&useLevel=" + $('#useLevel').val();
        }

        $.ajax({
            type:"POST",
            url:"${web_base}/recharge/card_info!updateByImportBatchNum.htm",
            data:data,
            success:function (data) {
                var dataObj =  data;
                if (dataObj == "success") {
                    alert("操作成功");
                } else {
                    alert("操作失败");
                }
            }
        });
    }
    function exportCard() {
        var data = $('#queryForm').serialize();
        var url = "${web_base}/recharge/card_info!export.htm?" + data;
        $('#download').attr('src',url);
    }
</script>
</@header>
<body class="list">
<div class="body">
    <div class="listBar">
        <h1><span class="icon">&nbsp;</span>卡密批量操作</h1>
    </div>

    <div class="operateBar">
        <form id="queryForm" action="" onsubmit="return false;">
            <label>导入时间:</label>
            <input type="text" name="importDate" id="importDate" onclick="WdatePicker({readOnly:true})" class="Wdate"
                   value="${importDate!}"
                   id="cardName"/>
            <button type="button" onclick="queryImportBatch('importBatchNum');">查询</button>
            <br>
            <label>选择批号:</label><select id="importBatchNum" name="importBatchNum">
            <option value="">--请选择--</option>
        </select><label>设置优先级:</label><select name="useLevel" id="useLevel">
            <option value="5">普通</option>
            <option value="9">优先</option>
        </select>
            <br>
            <button type="button" onclick="functionOpt('1','1');">启用</button>
            <button type="button" onclick="functionOpt('1','0');">禁用</button>
        <#--     <button type="button" onclick="">检查并清算</button> -->
            <button type="button" onclick="functionOpt('2');">退卡</button>
            <button type="button" onclick="exportCard();">导出</button>
            <button type="button" onclick="functionOpt('3','0');">设置优先级</button>
        </form>
    </div>
</div>
<iframe id="download" style="display: none;"></iframe>
</body>
</html>